package linear.stack;

import linear.stack.base.MyArrayStack;
import linear.stack.base.MyLinkedStack;
import linear.stack.base.MyStack;

/**
 * @author yeyangtao created at 11:21 2020/9/22
 */
public class TestDemo {
    public static void main(String[] args) {
        MyStack<Integer> stack = new MyArrayStack<>();
        MyStack<Integer> stack1 = new MyLinkedStack<>();
        test(stack1);
    }

    static void test(MyStack<Integer> stack) {
        System.out.println(stack + " size:" + stack.size());
        stack.push(1);
        stack.push(2);
        System.out.println(stack + " size:" + stack.size());

        System.out.println(stack.peek());
        System.out.println(stack + " size:" + stack.size());

        System.out.println(stack.pop());
        System.out.println(stack + " size:" + stack.size());
        System.out.println(stack.pop());
        System.out.println(stack + " size:" + stack.size());

        System.out.println(stack.isEmpty());

        for (int i = 0; i < 20; i++) {
            stack.push(i);
        }
        System.out.println(stack + " size:" + stack.size());
    }
}
